package com.xintai.system.service.impl;

import java.util.List;

import com.xintai.system.domain.setother.ErpOtherBangYingResult;
import com.xintai.system.domain.setother.ErpOtherList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xintai.system.mapper.ErpOtherMapper;
import com.xintai.system.domain.setother.ErpOther;
import com.xintai.system.service.IErpOtherService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 磅盈设置Service业务层处理
 * 
 * @author xintai
 * @date 2021-01-15
 */
@Service
public class ErpOtherServiceImpl implements IErpOtherService 
{
    @Autowired
    private ErpOtherMapper erpOtherMapper;

    @Override
    @Transactional
    public int insertBangYing(ErpOtherList erpOtherList) {

        erpOtherMapper.deleteErpOtherBangYing();

        int resultRow = 0;
        for (int i = 0; i < erpOtherList.getErpOtherList().size(); i++){
            erpOtherMapper.insertBangYing(erpOtherList.getErpOtherList().get(i));
            ++resultRow;
        }
        return resultRow;
    }

    @Override
    public ErpOtherBangYingResult selectBangYingList() {
        List<ErpOther> erpOtherList = erpOtherMapper.selectBangYingList();
        ErpOtherBangYingResult result = new ErpOtherBangYingResult();
        for (int i = 0; i < erpOtherList.size(); i++ ){
            ErpOther erpOther = erpOtherList.get(i);
            if ( erpOther.getOtherType() == 0 )
                result.setSxinput(erpOther.getOtherValue());

            if ( erpOther.getOtherType() == 1 )
                result.setSxout(erpOther.getOtherValue());

            if ( erpOther.getOtherType() == 2 )
                result.setZyinput(erpOther.getOtherValue());

            if ( erpOther.getOtherType() == 3 )
                result.setZyout(erpOther.getOtherValue());

            if ( erpOther.getOtherType() == 4 )
                result.setDxinput(erpOther.getOtherValue());

            if ( erpOther.getOtherType() == 5 )
                result.setDxout(erpOther.getOtherValue());

            if ( erpOther.getOtherType() == 6 )
                result.setCtinput(erpOther.getOtherValue());

            if ( erpOther.getOtherType() == 7 )
                result.setCtout(erpOther.getOtherValue());
        }
        return result;
    }
}
